import java.util.Scanner;

/*
    @author:sa
    @date:2024/11/11 9:07
*/
public class HomeWark {
        public static  int add(Scanner scanner, String stc[][],int i){
            String[] tea = new String[3];
            System.out.println("请输入姓名");
            tea[0] = scanner.nextLine();
            System.out.println("请输入年龄");
            tea[1] = scanner.nextLine();
            System.out.println("请输入性别");
            tea[2]  = scanner.nextLine();
            stc[i] = tea;
            i++;
            return i;
        }
    public static void main(String[] args) {
        System.out.println("请输入用户名");
        Scanner scanner = new Scanner(System.in);
        String userName = scanner.nextLine();
        System.out.println("请输入密码");
        String password = scanner.nextLine();
        boolean b1 = userName.equals("zhangsan");
        boolean b2 = password.equals("123");
        String[][] stc = new String[50][3];
        int i = 0;
        if (b1 && b2) {
            for (int s1 = 0; s1 <= 5; s1++) {
                System.out.println("1.新增2.修改3.删除4.查询5.退出");
                String choice = scanner.nextLine();
                switch (choice) {
                    case "1":
//                        String[] tea = new String[3];
//                        System.out.println("请输入姓名");
//                        String name = scanner.nextLine();
//                        tea[0] = name;
//                        System.out.println("请输入年龄");
//                        String age = scanner.nextLine();
//                        tea[1] = age;
//                        System.out.println("请输入性别");
//                        String sex = scanner.nextLine();
//                        tea[2] = sex;
//                        stc[i] = tea;
                        i=add(scanner, stc, i);
                        break;
                    case "2":
                        System.out.println("请输入要修改人的姓名");
                        String name = scanner.nextLine();
                        for (int x = 0; x < i; x++) {
                            if (stc[x][0].equals(name)) {
                                System.out.println("请输入要修改人的年龄");
                                String age = scanner.nextLine();
                                stc[x][1] = age;
                            } else {
                                break;
                            }
                        }
                        break;
                    case "3":
                        System.out.println("请输入要删除信息人的姓名");
                         name = scanner.nextLine();
                        for (int y = 0; y < i; y++) {
                            if (stc[y][0].equals(name)) {
                                stc[y][0] = null;
                                stc[y][1] = null;
                                stc[y][2] = null;
                            }
                        }
                        break;
                    case "4":
                        extracted(i, stc);
                        break;
                    case "5":
                        System.out.println("退出");
                        break;
                }
                if (choice.equals("5")) {
                    break;
                }
            }
        } else {
            System.out.println("登录失败");
        }
    }

    private static void extracted(int i, String[][] stc) {
        for (int j = 0; j < i; j++) {
            System.out.println("姓名：" + stc[j][0]);
            System.out.println("年龄：" + stc[j][1]);
            System.out.println("性别：" + stc[j][2]);
        }
        return;
    }
}
